package lib

import (
	espoirCom "gitee.com/jamon/espoir_go/common"
)

// 消息ID = 模块ID*BaseRange + 模块内消息ID

// 模块ID
const (
	MsgID_MODULE_ACCOUNT = 1 // 账号相关
	MsgID_MODULE_ROOM    = 2 // 房间相关

	MsgID_MODULE_PROXY = 100 // proxy本地处理消息
	MsgID_MODULE_PUSH  = 500 // 推送相关
)

const ModuleMsgRangeLen = 1000 // 每个模块的消息长度范围

// 消息ID
const (
	// 账号相关, 1000 - 1999
	MsgID_ACCOUNT_REGISTER   = MsgID_MODULE_ACCOUNT*ModuleMsgRangeLen + 1 // 注册 1001
	MsgID_ACCOUNT_LOGIN      = MsgID_MODULE_ACCOUNT*ModuleMsgRangeLen + 2 // 登录 1002
	MsgID_ACCOUNT_LOGOUT     = MsgID_MODULE_ACCOUNT*ModuleMsgRangeLen + 3 // 登出 1003
	MsgID_ACCOUNT_SWITCH_NET = MsgID_MODULE_ACCOUNT*ModuleMsgRangeLen + 4 // 切换网络 1004

	// 房间相关 2000 - 2999
	MsgID_ROOM_CREATE     = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 1 // 创建房间 2001
	MsgID_ROOM_JOIN       = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 2 // 加入房间 2002
	MsgID_ROOM_LEAVE      = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 3 // 离开房间 2003
	MsgID_ROOM_READY      = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 4 // 准备 2004
	MsgID_ROOM_START      = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 5 // 开始 2005
	MsgID_ROOM_GAME_OVER  = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 6 // 结束 2006
	MsgID_ROOM_GAME_OP    = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 7 // 房间内游戏操作 2007
	MsgID_ROOM_DISMISS    = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 8 // 解散房间 2008
	MsgID_ROOM_JOIN_MATCH = MsgID_MODULE_ROOM*ModuleMsgRangeLen + 9 // 加入匹配 2009

	// proxy本地处理消息 100000 - 100999

	MsgID_PROXY_HEARTBEAT = MsgID_MODULE_PROXY*ModuleMsgRangeLen + 1 // 心跳 100001

	//推送相关

	MsgID_PUSH_OTHER_LOGIN = MsgID_MODULE_PUSH*ModuleMsgRangeLen + 1 // 其他地方登录 500001

	MsgID_PUSH_FRAME_SYNC       = MsgID_MODULE_PUSH*ModuleMsgRangeLen + 100 // 帧同步 500100
	MsgID_PUSH_OTHER_USER_LOGIN = MsgID_MODULE_PUSH*ModuleMsgRangeLen + 101 // 局内其他玩家登录 500101
)

func OverrideInnerMsgID() {
	espoirCom.DefaultInnerMsgIDs.SwitchNetMsgID = MsgID_ACCOUNT_SWITCH_NET
	espoirCom.DefaultInnerMsgIDs.FrameSyncMsgID = MsgID_PUSH_FRAME_SYNC
	espoirCom.DefaultInnerMsgIDs.LenRange = ModuleMsgRangeLen
}
